﻿@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理员登录</title>
    <link href="@Url.BundleContent("~/css/style.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.BundleContent("~/Scripts/jquery-1.10.2.min.js")" type="text/javascript"></script>
    <script src="@Url.BundleContent("~/Scripts/json2.js")" type="text/javascript"></script>
    <script src="@Url.BundleContent("~/Scripts/errorCode.js")" type="text/javascript"></script>
    <script src="@Url.BundleContent("~/Scripts/jqueryStatic.js")" type="text/javascript"></script>
    <script type="text/javascript">
        function loginSubmit() {
            if ($("#txtUserName").val().replace(' ', '') == '') {
                $("#msgtip").html("请输入用户名").css("color", "red");
                $("#txtUserName").select();
                return false;
            }
            if ($("#txtPassword").val().replace(' ', '') == '') {
                $("#msgtip").html("请输入密码").css("color", "red");
                $("#txtPassword").select();
                return false;
            }

            var postdata = {
                loginid: $("#txtUserName").val(),
                pwd: $("#txtPassword").val()
            }

            $.ajax({
                url: '@Url.Action("AuthorizeUser")',
                type: "post",
                data: JSON.stringify(postdata),
                dataType: "json",
                processData: false,
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    errorCode.getMsg(data, function () {
                        if (data.success) {
                            document.location.href = "@ViewBag.ReturnUrl";
                        } else {
                            $("#msgtip").html("用户名密码错误").css("color", "red");
                            $("#txtPassword").val("");
                            $("#txtUserName").select();
                        }
                    }, function (e) {
                        $("#msgtip").html(e.msg + (data.msg == '' ? '(' + data.msg + ')' : '')).css("color", "red");
                    });
                }
            });
            return false;
        };

        $(function () {
            //检测IE
            if ('undefined' == typeof (document.body.style.maxHeight)) {
                window.location.href = '/admin/ie6update';
            };

            $("#btnSubmit").click(loginSubmit);

            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    loginSubmit();
                }
            }
        });
    </script>
</head>

<body class="loginbody">
    <div class="login-screen">
        <div class="login-form">
            <h1>管理系统后台</h1>
            <div class="control-group">
                <input name="txtUserName" type="text" value="" id="txtUserName" class="login-field" placeholder="用户名" title="用户名" />
                <label class="login-field-icon user" for="txtUserName"></label>
            </div>
            <div class="control-group">
                <input name="txtPassword" type="password" id="txtPassword" class="login-field" placeholder="密码" title="密码" />
                <label class="login-field-icon pwd" for="txtPassword"></label>
            </div>
            <div>
                <input type="button" name="btnSubmit" value="登 录" id="btnSubmit" class="btn-login" />
            </div>
            <span class="login-tips"><i></i><b id="msgtip">请输入用户名和密码</b></span>
        </div>
    </div>
</body>
</html>
